import $ from 'jQuery';
(function () {
    let storeParams = JSON.parse(IOT.getSessionStore(URI.OPERATE.GROUPS.DETAIL.PAGE));
    let $vue = new Vue({
        el: '.groups-detail-hook',
        data: {
            account: {
                "cTime": "",
                "cUser": "",
                "groupCode": "",
                "groupName": "",
                "groupNote": "",
                "proId": "",
                "userId": "",
                "groupState": "",
                "proName": "",
                "userName": ""
            }
        },
        created: function () {
            this.account = storeParams;
            /*IOT.getServerData(URI.OPERATE.GROUPS.DETAIL.DATA, {params: storeParams.params}, (ret) => {
                if (ret.code === 200) {
                    this.account = $.extend({}, this.account, ret.data);
                } else {
                    IOT.tips(ret.message || '服务器请求失败，稍后再试！', 'error');
                }
            });*/
        },
        methods: {
            goBack: function () {
                M.Page.emitPrePage();
            },
            lightPlan:function () {/*照明计划页面*/
                M.Page.emit(URI.OPERATE.GROUPS.DETAIL.PLAN);
            }
        },
        mounted: function () {
            this.$nextTick(() => {
                let tableHookName = $('.groupsDetail-table-hook');
                var $tableHook =tableHookName.bootstrapTable({
                    scrollbar: 'groupsDetail-table-body',
                    striped: true, // 设置为 true 会有隔行变色效果
                    pagination: true, // true 显示分页
                    paginationDetail: true, // 分页详情
                    sidePagination: 'server', // 服务器端
                    method: 'post',
                    url: URI.OPERATE.GROUPS.DETAIL.LIST,
                    debug: false,
                    cache: false,
                    pageNumber: 1,
                    pageSize: 10,
                    pageList: [10, 20, 50, 100],
                    // fixedColumns: true,
                    customButton: '',
                    customQueryParams: function (params) {
                        params.groupCode = storeParams.groupCode;
                        return params;
                    },
                    onLoadSuccess: function (data) {
                        //console.log(JSON.stringify(data));
                    },
                    onLoadError: function (status, xhr) {
                    },
                    columns: [
                        {
                            field: 'lightCode', title: '单灯编号', align: 'center', fixedLeft: true,tips:true
                        },
                        {
                            field: 'lightName', title: '单灯名称', align: 'center', fixedLeft: true,tips:true
                        },
                        {
                            field: 'onenetCode', title: '终端编号', align: 'center', fixedLeft: true,tips:true
                        },
                        {
                            field: 'imei', title: 'IMEI号', align: 'center', fixedLeft: true,tips:true
                        },
                        {
                            field: 'imsi', title: 'IMSI号', align: 'center',fixedLeft: true,tips:true
                        },
                        {
                            field: 'states', title: '状态', align: 'center',fixedLeft: true,tips:true,
                            formatter: function (val, rowData, index) {
                                if(val == 0){
                                    val = '开灯';
                                }else if(val == 1){
                                    val = '关灯';
                                }else if(val == 2){
                                    val = '故障';
                                }else if(val == 3){
                                    val = '离线';
                                }else{
                                    val = '其他';
                                }
                                return val;
                            }
                        },
                        {
                            field: 'installTime', title: '安装时间', align: 'center', fixedLeft: true,tips:true,
                            formatter: function (val, row, index) {
                                return val;
                            }
                        }
                    ]
                });
                //权限——查看
                if (!M.Authority.checkAuthority('account-detail')&&!M.Authority.checkAuthority('account-modify')) {
                    $(tableHookName).bootstrapTable('hideColumn', 'operate');//隐藏列
                }
            });
        }
    });
})();